﻿using System;
using System.Linq;

namespace Controllers
{
    public class DelMethodsController : BaseController
    {
        //培训需求
        public string TrainNeeds(string formNo)
        {
            string retStr = "Succeed";
            TrainNeed oriObj = ctx.TrainNeeds.Single(r => r.FormNo == formNo);
            ctx.TrainNeeds.DeleteOnSubmit(oriObj);
            try
            {
                ctx.SubmitChanges();
            }
            catch (Exception ex)
            {
                retStr = ex.Message;
            }
            return retStr;
        }
        //培训计划
        public string TrainSchemes(string formNo)
        {
            string retStr = "Succeed";
            TrainScheme oriObj = ctx.TrainSchemes.Single(r => r.FormNo == formNo);
            ctx.TrainSchemes.DeleteOnSubmit(oriObj);
            try
            {
                ctx.SubmitChanges();
            }
            catch (Exception ex)
            {
                retStr = ex.Message;
            }
            return retStr;
        }
        //试题
        public string Question(int id)
        {
            string retStr = "Succeed";
            ExamQuestion oriObj = ctx.ExamQuestions.Single(r => r.Id == id);
            ctx.ExamQuestions.DeleteOnSubmit(oriObj);
            try
            {
                ctx.SubmitChanges();
            }
            catch (Exception ex)
            {
                retStr = ex.Message;
            }
            return retStr;
        }
    }
}